<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .demo {
            width: 400px;
            height: 800px;
            margin: auto;
        }

        .tou {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .tou h2 {
            width: 100px;
            height: 50px;
            border: 1px solid gray;
            box-sizing: border-box;
            text-align: center;
            line-height: 50px;
            font-size: 20px;
        }

        #con {
            height: 750px;
            width: 400px;
            border: 1px solid gray;
            box-sizing: border-box;
            border-top: none;
        }
    </style>
</head>

<body>
    <main class="demo">
        <div class="tou">
            <h2 style="">疫情</h2>
            <h2 style="">体育</h2>
            <h2 style="">娱乐</h2>
            <h2 style="">政界</h2>
        </div>
        <div id="con"></div>
    </main>
    <script>
        var h = document.getElementsByTagName("h2")
        var c = document.getElementById("con")
        for (var i = 0; i < h.length; i++) {
            h[i].onclick = function () {
                for (var j = 0; j < h.length; j++) {
                    h[j].style.background = ""
                }
                this.style.backgroundColor = "red"
                c.innerHTML = this.innerText010011
            }
        }
    </script>
</body>

</html>